package cc.mycraft.events;

import java.util.Date;

import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

import cc.mycraft.EventLoader;
import cc.mycraft.MYCPlugin;

public final class PlayerBackEvent extends Event implements Cancellable{
	
	private static final HandlerList handlers = new HandlerList();

	@Override
	public HandlerList getHandlers() {
		return handlers;
	}
	
	public static HandlerList getHandlerList() {
		return handlers;
	}
	
	private boolean isReload;
	private long time;
	private MYCPlugin PG;
	private Location backLoc;
	private Player backPlayer;
	private boolean cancelled;
	
	public PlayerBackEvent(MYCPlugin p,Player player,Location Loc) {
		this.PG = p;
		this.backPlayer = player;
		this.backLoc = Loc;
		this.time = new Date().getTime();
		this.isReload = this.time-EventLoader.startTime > 60000l;
	}
	
	public void teleport() {
		this.backPlayer.teleport(this.backLoc);
	}
	
	public boolean isReload() {
		return this.isReload;
	}
	
	public MYCPlugin getPlugin() {
		return this.PG;
	}

	public boolean isCancelled() {
		return this.cancelled;
	}
	public void setCancelled(boolean b) {
		this.cancelled = b;
	}
}
